import { get } from '@/utils/request'
import request from '@/utils/request'

/**
 * 获取数据概览
 * @returns {Promise<{
 *   totalUsers: number,
 *   newUsers: number,
 *   avgHeight: number,
 *   avgWeight: number,
 *   trends: {
 *     userTrend: number,
 *     newUserTrend: number,
 *     heightTrend: number,
 *     weightTrend: number
 *   }
 * }>}
 */
export function getDataOverview() {
  return get('/statistics/overview')
}

/**
 * 获取身高分布数据
 * @returns {Promise<Array<{ name: string, value: number }>>}
 */
export function getHeightDistribution() {
  return get('/statistics/height-distribution')
}

/**
 * 获取体重分布数据
 * @returns {Promise<Array<{ name: string, value: number }>>}
 */
export function getWeightDistribution() {
  return get('/statistics/weight-distribution')
}

/**
 * 获取BMI分布数据
 * @param {string} ageGroup - 年龄组 '3-6'|'7-12'|'13-16'
 * @returns {Promise<Array<{ name: string, value: number }>>}
 */
export function getBMIDistribution(ageGroup) {
  return get('/statistics/bmi-distribution', { params: { ageGroup } })
}

/**
 * 获取年龄分布数据
 * @returns {Promise<Array<{ name: string, value: number }>>}
 */
export function getAgeDistribution() {
  return get('/statistics/age-distribution')
}

/**
 * 获取数据分析概览
 * @returns {Promise} 返回数据分析结果
 */
export function getDataAnalysis() {
  return request({
    url: '/admin/analysis/overview',
    method: 'get'
  })
} 